;This is the bootstrap that loads at track 0 sector 1
;it will be put into memory at 80H by the cold boot in the ROM based BIOS
;then it will be executed and read in the next 51 sectors.
;Note the ROM BIOS has already figured out density of disk & is stored
;as bit 6 @ 42H. (eg. for drive A: 40=dd  00=sd)
;
MSIZE:	EQU	60	     ;<-----------------------------
PROM:	EQU	0F800H	     ;<-----------------------------
LOADER:	EQU	PROM+39H
;
CBASE:	EQU	(MSIZE-21)*1024	;BIAS FOR CPM LARGER THAN 17K <-------
			     	;NOTE I HAVE A 2K "BIOS" TO LEAVE ROOM FOR
				;A VDM BOARD AT EC00H (YOU MAY WANT TO CHANGE
				;THIS)
CCP:	EQU	CBASE+3400H  	;START OF CCP
BDOS:	EQU	CCP+806H     	;START OF BDOS
BIOS:	EQU	CCP+1600H    	;START OF BIOS
;
CDISK:	EQU	04H
TADDR:	EQU	40H
UNIT:	EQU	42H
SCTR:	EQU	43H
NREC:	EQU	45H
CBFLAG:	EQU	5AH	     ;0 FROM BIOS TO INDICATE WBOOT	
;
MONITOR:EQU	0F000H
CO:	EQU	MONITOR+9H
;
	ORG	80H
	LD	SP,80H
	LD	A,0C3H	     ;SETUP JUMPS
	LD	(0H),A
	LD	HL,BIOS+3    ;SETUP JUMP TO WBOOT
	LD	(1),HL
	LD	(5),A
	LD	HL,BDOS	     ;SETUP JUMP TO BDOS
	LD	(6),HL
	LD	A,02H
	LD	(SCTR),A     ;HAS ALREADY SELECTED DRIVE A: TRACK 0
	LD	A,(CBFLAG)   ;IS IT A COLD BOOT OR WBOOT
	OR	A
	JR	Z,WBOOT
	LD	A,51	     ;TRANSFERR 51 SECTORS FOR COLD BOOT
	JR	CBOOT
WBOOT:	LD	A,45	     ;NEED TRANSFERR ONLY 45 FOR WARM BOOT
CBOOT:	LD	(NREC),A
	LD	HL,CCP
	LD	(TADDR),HL
	CALL	LOADER	     ;TO BIOS TO LOAD IN "N" CONTIGOUS SECTORS
	JR	NZ,ERROR
	LD	A,(CBFLAG)   ;IS IT A COLD BOOT OR WARM BOOT
	OR	A
	JR	Z,WBOOT1     ;IF ZERO THEN NOT A COLD BOOT
	LD	HL,MSG1	     ;SIGNON WITH CP/M & ITS SIZE
	CALL	PRINT
WBOOT1:	LD	A,(CDISK)    ;RESTORE CURRENT DISK (OR A: FOR COLD BOOT)
	LD	C,A
	JP	CCP
;
ERROR:	LD	HL,MSG2
	CALL	PRINT
	HALT
;
;
PRINT:	LD	A,(HL)
	OR	A
	RET	Z
	LD	C,A
	CALL	CO
	INC	HL
	JR	PRINT
;
MSG1:	DB	0DH,07H,1CH,09H,09H,15H
	DB	MSIZE/10 + '0',MSIZE MOD 10 +'0'
	DB	'K CP/M.' 
	DB	11H,0AH,0DH,0H
;
MSG2:	DB	0DH,0AH,'LD ERROR',0H
FINISH	EQU	$
END:	
